<?php

class Application_Model_Front_User
{

    public static function setModel(Application_Model_User $model)
    {
        $session             = Zend_Registry::get('session');
        $session->user_model = $model;
        Zend_Registry::set('session', $session);

        return !empty($session->user_model);
    }

    public static function isLoggedIn()
    {
        $session = Zend_Registry::get('session');
        return !empty($session->user_model);
    }

    public static function getModel()
    {
        $model = null;

        $session = Zend_Registry::get('session');
        if (!empty($session->user_model) && $session->user_model instanceof Application_Model_User)
        {
            $model = $session->user_model;
        }

        return $model;
    }

    public static function destroyModel()
    {
        $session             = Zend_Registry::get('session');
        $session->user_model = null;
        Zend_Registry::set('session', $session);

        return !self::isLoggedIn();
    }

}